package com.jly.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jly.controller.dto.UserPasswordDTO;
import com.jly.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
@Mapper
@Repository
public interface userMapper  extends BaseMapper<User> {
    @Select("Select * from user")
    List<User> findAll();
    // 分页查询数据
    List<User> selectByPage(Page<User> page);
    List<User> searchByPage(@Param("username") String username,
                            @Param("email") String money,
                            @Param("address") String address,
                            Page<User> page);

    @Update("update sys_user set password = #{newPassword} where username = #{username} and password = #{password} ")
    int UpdatePassword(UserPasswordDTO userPasswordDTO);

    Page<User> findPage(Page<User> page,
                        @Param("username") String username,
                        @Param("email") String email,
                        @Param("address") String address);}
